#include "music.h"
char cmd[256];
extern Head_List * mp3_list;
int next_action=0;
extern int music;
void* music_run(void* arg)
{
    fNode* p = mp3_list->first; 
    while(p)
    {       
        //获取用户的操作 
        if(next_action == 1)
        {
            system("pkill -9 madplay"); //干掉当前播放的音乐
            p = p->next;
            sprintf(cmd, "madplay -Q jpg/%s &", p->filename);
            system(cmd);
            next_action=0;
            printf("now:%s\n",p->filename);
        }
        else if(next_action == 2)
        {
            if(music==0)
            {
                system("pkill -9 madplay"); //干掉当前播放的音乐
            }
            else
            {
                sprintf(cmd, "madplay -Q jpg/%s &", p->filename);
                system(cmd);
                
            }
            printf("now:%s\n",p->filename);
            next_action=0;
        }
        else if(next_action==3)
        {
            system("pkill -9 madplay"); //干掉当前播放的音乐
            p = p->prev;
            sprintf(cmd, "madplay -Q jpg/%s &", p->filename);
            system(cmd);
            printf("now:%s\n",p->filename);
            next_action=0;
        }
        
    }
}